package com.wk2un11.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.wk2un11.entity.HomeInfo;
import com.wk2un11.util.DBManage;

public class HomeinfoDao {

	public static HomeInfo gethomeinfo() {
		HomeInfo homeInfo = null;
		try {
			Connection conn = DBManage.getConn();
			Statement stam = conn.createStatement();
			String sql = "select * from homeinfo";
			ResultSet rs = stam.executeQuery(sql);
			while (rs.next()) {
				int id = rs.getInt("id");
				String homeIntro = rs.getString("homeIntro");
				String info = rs.getString("info");
				String culture = rs.getString("culture");
				String zsTel = rs.getString("zsTel");
				String lxTel = rs.getString("lxTel");
				String email = rs.getString("email");
				String address = rs.getString("address");
				double x = rs.getDouble("x");
				double y = rs.getDouble("y");
				homeInfo = new HomeInfo(id, homeIntro, info, culture, zsTel, lxTel, email, address, x, y);
			}
			DBManage.colseAll(rs, stam, conn);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return homeInfo;
	}
}
